Skip to content

feat(rebrand): env T3CODE_* → BCODE_*, protocol t3:// → bcode://, COM/Linux IDs#9

Merged
Berkay2002 merged 13 commits intomainfrom
rebrand/env-protocol-com
Apr 17, 2026
Merged

feat(rebrand): env T3CODE_* → BCODE_*, protocol t3:// → bcode://, COM/Linux IDs#9
Berkay2002 merged 13 commits intomainfrom
rebrand/env-protocol-com

Conversation

@Berkay2002
Copy link
Copy Markdown
Owner

@Berkay2002 Berkay2002 commented Apr 17, 2026

Summary

PR #2 of the deep identifier rebrand (PR #1 merged as d91a66e). Flips the env var prefix, desktop internal protocol scheme, COM/bundle ID, Linux desktop entry + WM class, shell capture sentinels, and the internal bootstrap/metadata field names. Ships with a one-release dual-read shim so existing `T3CODE_*` environments keep working with a deprecation warning through v0.0.19 (removed in v0.0.20).

Env var dual-read shim

  • New `packages/shared/src/env.ts` with `readEnv(suffix)` — prefers `BCODE_`, falls back to `T3CODE_`, emits a one-time `[bcode]` console warning per legacy key.
  • Effect `Config` helpers with the same fallback in `apps/server/src/cli.ts`, `scripts/dev-runner.ts`, and `scripts/build-desktop-artifact.ts`.
  • All user-facing docs flip to `BCODE_*`. A deprecation-window note is added at the top of `docs/observability.md` § Configuration.

Desktop / COM / Linux identifiers

  • `DESKTOP_SCHEME`: `t3://` → `bcode://`. Internal-only asset scheme — no OS-level handler was ever registered, so no migration shim needed.
  • `APP_USER_MODEL_ID` (Windows AUMID), `APP_BUNDLE_ID` (macOS plist patcher), and electron-builder `appId` → `com.berkayorhan.bcode`.
  • `artifactName` pattern → `BCode-${version}-${arch}.${ext}` (release-smoke + update-manifest fixtures flipped to match).
  • `LINUX_DESKTOP_ENTRY_NAME`, `LINUX_WM_CLASS`, electron-builder `executableName`, and `StartupWMClass` all flip to `bcode`.

Internal names also flipped in this PR

Not in the original plan doc but caught by grep during execution — all self-contained to this repo, no cross-install migration concerns:

  • `bcodeCommitHash` metadata field (build writes, main.ts reads — both flipped atomically).
  • `--bcode-dev-root=` flag used by `dev-electron.mjs` for pkill marker filtering.
  • Packaged stage `package.json` name field and electron-builder temp-dir prefixes.
  • Shell capture sentinels `_BCODE_PATH` / `_BCODE_ENV`.
  • Bootstrap envelope field `t3Home` → `bcodeHome`.
  • Default `otlpServiceName`: `t3-server` → `bcode-server`.

Deliberate keeps (per AGENTS.md:23–26)

  • `USER_DATA_DIR_NAME = "t3code"` (electron's per-app userData subdir) — preserves existing installs' window state, cookies, renderer cache.
  • `LEGACY_USER_DATA_DIR_NAME` and `LEGACY_T3_HOME_DIR_NAME` — referenced only by migration code.
  • `~/.t3` home directory and `t3code:*` localStorage — deferred to PR chore(release): rewire pipeline for fork-owned releases #3 with auto-migration.

Dual-prefix listings

  • `turbo.json` `globalEnv` lists both `BCODE_` and `T3CODE_` entries. Dropping legacy entries while the shim still honors them would let stale cache hide dual-read bugs. The `T3CODE_*` lines are removed together with the shim in v0.0.20.
  • `packages/shared/src/projectScripts.ts` writes both `BCODE_PROJECT_ROOT` and `T3CODE_PROJECT_ROOT` to spawned project scripts so user-authored scripts still work without changes. Removed in v0.0.20.
  • `apps/desktop/scripts/electron-launcher.mjs` has no inline shim — it reads no env vars that needed one (confirmed by grep). Its own COM/app-display identifiers remain intact for now (tied to the UI rebrand, not this PR).

Disclosures

  • Pre-existing Windows test failures: `apps/server` shows ~24 failures on Windows (e.g. `Manager.test.ts#833`, expectations about resolved shell paths). This matches the `~23` baseline disclosed in the PR fix: align web test fixtures with ServerProvider contract #1 context. CI (Ubuntu) is authoritative. I did not try to fix these inline — delegated to `/bugfix` if it grows.
  • Telemetry env vars (`BCODE_POSTHOG_`, `BCODE_TELEMETRY_`): flipped cleanly without the shim because they're documented internal to the analytics pipeline. Users exporting `T3CODE_POSTHOG_*` will need to rename before upgrading. Documented implicitly via the v0.0.19 release notes.

Test plan

  • `bun run fmt` — zero diff
  • `bun run lint` — 0 errors (12 pre-existing warnings)
  • `bun run typecheck` — all 8 packages green
  • New unit test in `packages/shared/src/env.test.ts` covers: BCODE_ preferred, T3CODE_ fallback + one-shot warn, undefined when neither set, empty string as set value, distinct warnings per legacy key.
  • New regression test in `apps/server/src/cli-config.test.ts` asserts `T3CODE_HOME` fixture still resolves and emits a `T3CODE_HOME.*deprecated` warning.
  • `bun run --cwd packages/shared test` — 18 passing (env + shell).
  • `bun run --cwd scripts test` — merge-mac-update-manifests green with flipped fixtures.
  • CI green (Ubuntu)
  • Copilot / pr-review-toolkit review addressed

BCODE_* preferred with T3CODE_* fallback + per-key deprecation warning.
Rename bootstrap envelope field t3Home -> bcodeHome. Default
otlpServiceName flips from t3-server to bcode-server.
Desktop app.ts, updateState, terminal Manager, perf harnesses, telemetry,
projectScripts, vite/web, dev-runner, build-desktop-artifact, mock-update
and misc tests move to BCODE_*. Scripts with user-facing env (dev-runner,
build-desktop-artifact) keep a BCODE_* preferred / T3CODE_* fallback shim
that warns once per legacy key. projectScriptRuntimeEnv writes both
prefixes so user-authored project scripts continue reading legacy names.
Terminal env strip filter now drops both BCODE_* and T3CODE_* keys.
Internal-only markers grep'd out of captured shell output. No persistence
or external interface, safe to flip without a legacy-name fallback.
Dual-listing matches the env var shim window: cache invalidation fires
when either prefix changes through v0.0.19. The T3CODE_* entries are
removed together with the shim in v0.0.20.
DESKTOP_SCHEME is an electron-internal asset protocol used for packaged
UI loading. No OS-level handler is registered via setAsDefaultProtocolClient,
so this flip has no external surface and needs no migration shim.
…factName to BCode-*

Flips APP_USER_MODEL_ID (Windows AUMID), APP_BUNDLE_ID (macOS plist patching
in the electron launcher), and the electron-builder appId + artifactName
pattern. Changes the installed-app identity on new installs; existing
installs continue to resolve their own identity via electron's userData
paths (deliberately kept under the legacy t3code name).
…tifiers to bcode

LINUX_DESKTOP_ENTRY_NAME, LINUX_WM_CLASS, executableName, StartupWMClass,
the dev-electron pkill marker arg, the packaged package.json name, the
temp stage dir prefixes, and the bcodeCommitHash metadata field all flip
to bcode. USER_DATA_DIR_NAME remains 't3code' deliberately (per AGENTS.md)
to preserve electron-managed state on existing installs.
Follows the commit 8 artifactName flip: update-manifest test fixtures
and release-smoke-test fixture URLs must match the new artifact naming
pattern or the tests fail on what's effectively stale hardcoded data.
Updates observability, release, perf-benchmarks, quick-start, scripts,
KEYBINDINGS, and debugging rule docs to use the new env var names and
home directory. Adds an env var deprecation-window note at the top of
observability.md. Historical plans and specs are left untouched.
The projectScriptRuntimeEnv helper writes both BCODE_* and T3CODE_*
aliases through v0.0.19 so user-authored project scripts keep reading
legacy names. The setup-script runner assertion must match that shape.
Other projectScripts/ChatView assertions already use toMatchObject
partial matching so they were unaffected.
- desktop main.ts:1412: write bcodeHome (not t3Home) to the bootstrap
  envelope so the server honors the desktop-selected base dir after the
  schema field rename.
- turbo.json: add BCODE_WEB_SOURCEMAP and T3CODE_WEB_SOURCEMAP to
  globalEnv so vite sourcemap changes invalidate turbo cache.
- build-desktop-artifact.ts: emit the one-time legacy-env deprecation
  warning for T3CODE_DESKTOP_UPDATE_REPOSITORY like the other shimmed
  reads.
- observability.md / KEYBINDINGS.md / debugging.md / scripts.md: revert
  hardcoded ~/.bcode/... paths to ~/.t3/... with a note about the
  upcoming home-dir flip. The runtime default is still ~/.t3 until PR #3
  lands the auto-migration, so user-facing docs must match the current
  on-disk reality. Env var name flips (BCODE_*) are retained since the
  shim honors both.
Copilot AI review requested due to automatic review settings April 17, 2026 15:36
@github-actions github-actions Bot added size:XL vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. labels Apr 17, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR is part of the deep identifier rebrand, switching runtime/config identifiers from T3CODE_* / t3:// / com.t3tools.t3code to BCODE_* / bcode:// / com.berkayorhan.bcode, while keeping a one-release env var fallback shim for most settings.

Changes:

  • Introduces a shared env reader shim (readEnv) and updates server/desktop/scripts/tests to prefer BCODE_* with fallback to T3CODE_* (with deprecation warnings in several entry points).
  • Rebrands desktop build identifiers (protocol scheme, appId/AUMID, Linux executable/WM class) and updates release/update manifest fixtures accordingly.
  • Updates docs and tests to reflect the new naming.

Reviewed changes

Copilot reviewed 47 out of 47 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
turbo.json Adds BCODE_* env keys to Turbo cache invalidation inputs (keeps T3CODE_* during shim window).
scripts/release-smoke.ts Updates mac update-manifest smoke fixtures to BCode-* artifact names.
scripts/open-perf-app.ts Renames perf env var keys to BCODE_PERF_*.
scripts/mock-update-server.ts Adds dual-read for mock update server env vars.
scripts/merge-mac-update-manifests.test.ts Updates test fixtures to BCode-* artifact names.
scripts/dev-runner.ts Adds BCODE_*/T3CODE_* Config fallback shim and updates dev-runner child env wiring.
scripts/dev-runner.test.ts Updates dev-runner tests for BCODE_* naming.
scripts/build-desktop-artifact.ts Rebrands electron-builder config (appId/artifactName/executableName/WM class) and adds BCODE_DESKTOP_* fallback shim for many build env vars.
scripts/build-desktop-artifact.test.ts Updates build script tests to set BCODE_DESKTOP_* env vars.
packages/shared/src/shell.ts Rebrands shell PATH/env capture sentinels to __BCODE_*.
packages/shared/src/shell.test.ts Updates sentinel-related tests for __BCODE_*.
packages/shared/src/projectScripts.ts Emits BCODE_* project/worktree env vars while keeping legacy T3CODE_* aliases.
packages/shared/src/env.ts Adds readEnv(suffix) dual-read helper with one-time legacy warning tracking.
packages/shared/src/env.test.ts Adds unit tests for readEnv behavior and warning semantics.
packages/shared/package.json Exposes @bcode/shared/env subpath export.
packages/contracts/src/terminal.test.ts Updates terminal schema test to use BCODE_PROJECT_ROOT.
docs/superpowers/plans/majestic-jumping-rocket.md Adds an execution breakdown/checklist for the PR.
docs/release.md Updates updater env var docs to BCODE_DESKTOP_UPDATE_*.
docs/perf-benchmarks.md Updates perf env var docs to BCODE_PERF_*.
docs/observability.md Updates observability env var names and adds deprecation-window note; updates example paths.
apps/web/vite.config.ts Adds BCODE_WEB_SOURCEMAP with legacy fallback.
apps/web/test/perf/supportHelpers.test.ts Updates perf env expectations to BCODE_*.
apps/web/test/perf/serverEnv.ts Renames perf env constants to BCODE_*.
apps/web/test/perf/appHarness.ts Renames perf harness env vars to BCODE_PERF_*.
apps/web/src/projectScripts.test.ts Updates tests to expect BCODE_* script env vars.
apps/web/src/components/ChatView.browser.tsx Updates test harness terminal env keys to BCODE_*.
apps/server/src/terminal/Layers/Manager.ts Excludes both BCODE_* and T3CODE_* from forwarded terminal env.
apps/server/src/terminal/Layers/Manager.test.ts Updates terminal manager tests to BCODE_* env keys.
apps/server/src/telemetry/Layers/AnalyticsService.ts Renames telemetry env vars to BCODE_* (no shim).
apps/server/src/telemetry/Layers/AnalyticsService.test.ts Updates telemetry tests to BCODE_*.
apps/server/src/project/Layers/ProjectSetupScriptRunner.test.ts Updates setup-script env fixtures to BCODE_*.
apps/server/src/perf/config.ts Renames perf env constants to BCODE_*.
apps/server/src/perf/PerfProviderAdapter.test.ts Renames perf scenario env key to BCODE_*.
apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts Adds BCODE_* fallback for strict lifecycle guard env var.
apps/server/src/git/Layers/CodexTextGeneration.test.ts Rebrands fake codex heredoc sentinel strings.
apps/server/src/cli.ts Rebrands bootstrap/config env vars to BCODE_*, adds dual-read shim, renames bootstrap field to bcodeHome, updates default OTLP service name.
apps/server/src/cli-config.test.ts Updates fixtures to BCODE_* and adds a regression test for T3CODE_HOME warning + behavior.
apps/server/integration/perf/serverPerfHarness.ts Renames perf env keys to BCODE_*.
apps/desktop/src/updateState.ts Updates disabled-by-env message to BCODE_DISABLE_AUTO_UPDATE.
apps/desktop/src/updateState.test.ts Updates assertion to match BCODE_DISABLE_AUTO_UPDATE.
apps/desktop/src/main.ts Switches to readEnv for base dir and other knobs, flips protocol scheme and desktop identifiers, updates commit-hash metadata keys, rebrands required desktop dev port env var name.
apps/desktop/scripts/electron-launcher.mjs Updates macOS bundle ID to com.berkayorhan.bcode(.dev).
apps/desktop/scripts/dev-electron.mjs Rebrands pkill marker flag --t3code-dev-root--bcode-dev-root.
KEYBINDINGS.md Updates documented keybindings path.
.docs/scripts.md Updates scripts doc references (protocol and env var names).
.docs/quick-start.md Updates quick-start env var to BCODE_DEV_INSTANCE.
.claude/rules/debugging.md Updates documented trace-file path example.
Comments suppressed due to low confidence (1)

packages/shared/src/projectScripts.ts:35

  • projectScriptRuntimeEnv now sets both BCODE_* and legacy T3CODE_* keys, but when extraEnv overrides (e.g. overrides BCODE_PROJECT_ROOT), the legacy aliases can diverge because the merge doesn’t synchronize them. That breaks the stated goal of keeping user-authored scripts working unchanged during the deprecation window. Consider normalizing after merging (e.g. if BCODE_PROJECT_ROOT is overridden and T3CODE_PROJECT_ROOT is not, set the legacy key to the same value; likewise for worktree path).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/observability.md Outdated
### Traces

Completed spans are written as NDJSON records to `serverTracePath` (by default, `~/.t3/userdata/logs/server.trace.ndjson`).
Completed spans are written as NDJSON records to `serverTracePath` (by default, `~/.bcode/userdata/logs/server.trace.ndjson`).
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This document now claims the default serverTracePath is under ~/.bcode/..., but the codebase still defaults the base dir to ~/.t3 (e.g. server/dev-runner/desktop). Until the home-dir migration in PR #3 lands, this default path is incorrect and will send users to the wrong location. Please revert the default-path examples to ~/.t3/... or describe it in terms of $BCODE_HOME (noting its current default).

Suggested change
Completed spans are written as NDJSON records to `serverTracePath` (by default, `~/.bcode/userdata/logs/server.trace.ndjson`).
Completed spans are written as NDJSON records to `serverTracePath` (by default, `$BCODE_HOME/userdata/logs/server.trace.ndjson`, where `$BCODE_HOME` currently defaults to `~/.t3`).

Copilot uses AI. Check for mistakes.
Comment thread .docs/scripts.md Outdated
- `bun run dev:server` — Starts just the WebSocket server (uses Bun TypeScript execution).
- `bun run dev:web` — Starts just the Vite dev server for the web app.
- Dev commands default `T3CODE_STATE_DIR` to `~/.t3/dev` to keep dev state isolated from desktop/prod state.
- Dev commands default `BCODE_STATE_DIR` to `~/.bcode/dev` to keep dev state isolated from desktop/prod state.
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doc states dev commands default BCODE_STATE_DIR to ~/.bcode/dev, but there doesn’t appear to be a BCODE_STATE_DIR env var in the codebase, and the current default base dir is still ~/.t3 (state dir becomes $BCODE_HOME/dev in monorepo dev). Update this line to reference the actual knob (BCODE_HOME / --base-dir) and the current default location.

Suggested change
- Dev commands default `BCODE_STATE_DIR` to `~/.bcode/dev` to keep dev state isolated from desktop/prod state.
- Dev commands use the normal base-dir knob (`BCODE_HOME` / `--base-dir`); the default base dir is `~/.t3`, so monorepo dev state lives under `$BCODE_HOME/dev` (by default `~/.t3/dev`) to keep dev state isolated from desktop/prod state.

Copilot uses AI. Check for mistakes.
Comment thread KEYBINDINGS.md Outdated
Comment on lines 5 to 6
- `~/.bcode/keybindings.json`

Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The keybindings path is documented as ~/.bcode/keybindings.json, but the server derives it from the configured base dir and state dir (typically $BCODE_HOME/userdata/keybindings.json in prod/desktop and $BCODE_HOME/dev/keybindings.json in monorepo dev; with the current default base dir still ~/.t3). Please update this path to match current behavior (or express it relative to $BCODE_HOME).

Suggested change
- `~/.bcode/keybindings.json`
- `$BCODE_HOME/<state-dir>/keybindings.json`
Typically this resolves to:
- `$BCODE_HOME/userdata/keybindings.json` in prod/desktop
- `$BCODE_HOME/dev/keybindings.json` in monorepo dev

Copilot uses AI. Check for mistakes.
Comment thread .claude/rules/debugging.md Outdated

# In production/CLI mode:
tail -f ~/.t3/userdata/logs/server.trace.ndjson
tail -f ~/.bcode/userdata/logs/server.trace.ndjson
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This trace-file location uses ~/.bcode/..., but the runtime still defaults the base dir to ~/.t3 (and the trace path is $BCODE_HOME/userdata/logs/server.trace.ndjson, with $BCODE_HOME defaulting to ~/.t3 until the PR #3 home-dir migration). Update this path so it matches the current on-disk location.

Suggested change
tail -f ~/.bcode/userdata/logs/server.trace.ndjson
tail -f ~/.t3/userdata/logs/server.trace.ndjson

Copilot uses AI. Check for mistakes.
Comment thread scripts/build-desktop-artifact.ts Outdated
Comment on lines 506 to 510
const rawRepo =
process.env.BCODE_DESKTOP_UPDATE_REPOSITORY?.trim() ||
process.env.T3CODE_DESKTOP_UPDATE_REPOSITORY?.trim() ||
process.env.GITHUB_REPOSITORY?.trim() ||
"";
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolveGitHubPublishConfig falls back to T3CODE_DESKTOP_UPDATE_REPOSITORY but doesn’t emit the one-time deprecation warning that the rest of the env dual-read shim provides in this script. For consistency (and to help users notice they’re still on legacy env), consider routing this through the existing fallback helper (or add an equivalent warning when the legacy key is used).

Copilot uses AI. Check for mistakes.
Comment thread turbo.json
Comment on lines 3 to +24
"globalEnv": [
"HOST",
"PORT",
"VITE_WS_URL",
"VITE_DEV_SERVER_URL",
"BCODE_LOG_WS_EVENTS",
"BCODE_MODE",
"BCODE_PORT",
"BCODE_NO_BROWSER",
"BCODE_HOME",
"BCODE_AUTH_TOKEN",
"BCODE_DESKTOP_WS_URL",
"BCODE_TRACE_MIN_LEVEL",
"BCODE_TRACE_TIMING_ENABLED",
"BCODE_TRACE_FILE",
"BCODE_TRACE_MAX_BYTES",
"BCODE_TRACE_MAX_FILES",
"BCODE_TRACE_BATCH_WINDOW_MS",
"BCODE_OTLP_TRACES_URL",
"BCODE_OTLP_METRICS_URL",
"BCODE_OTLP_EXPORT_INTERVAL_MS",
"BCODE_OTLP_SERVICE_NAME",
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apps/web/vite.config.ts now reads BCODE_WEB_SOURCEMAP/T3CODE_WEB_SOURCEMAP, which can change build output (sourcemap generation). Those env vars aren’t listed in turbo.json globalEnv, so Turbo may reuse cached build artifacts across different sourcemap settings. Consider adding both keys to globalEnv to ensure correct cache invalidation.

Copilot uses AI. Check for mistakes.
Comment thread apps/server/src/cli.ts
port: Schema.optional(PortSchema),
host: Schema.optional(Schema.String),
t3Home: Schema.optional(Schema.String),
bcodeHome: Schema.optional(Schema.String),
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BootstrapEnvelopeSchema was renamed to bcodeHome, but the desktop bootstrap envelope still appears to use the legacy t3Home field (see apps/desktop/src/main.ts). With the current schema, t3Home will be ignored and the base dir will fall back to env/defaults instead of the desktop-selected value. Update the producer to send bcodeHome (or keep a one-release dual-read by accepting both t3Home and bcodeHome in the schema during the deprecation window).

Suggested change
bcodeHome: Schema.optional(Schema.String),
bcodeHome: Schema.optional(Schema.String),
t3Home: Schema.optional(Schema.String),

Copilot uses AI. Check for mistakes.
@Berkay2002 Berkay2002 merged commit de84bc7 into main Apr 17, 2026
7 checks passed
@Berkay2002 Berkay2002 deleted the rebrand/env-protocol-com branch April 17, 2026 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants